{% load staticfiles %}
<!DOCTYPE html>
<html lang="zh-CN">
    <head>
        <meta charset="UTF-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <title>FinalProject|{{title}}</title>
        <link href="{% static 'css/bootstrap.css' %}" rel="stylesheet">
        <link href="{% static 'css/style.css' %}"  rel="stylesheet">
        <script src="{% static 'js/bootstrap.min.js' %}"></script>
        <script src="{% static 'js/jquery.min.js' %}"></script>
    </head>
    <body>
    <form action="" class="login">
        <p>Login</p>
        <input type="email" id="email" placeholder="邮箱">
        <input type="password" id="pwd" placeholder="密码">
        <button type="button" id="login" class="btn">登  录</button>
        <br>
        <a class="btn hidden" id="go" href="/hall/">GO!</a>
        <a class="btn" id="register" href="/register/">注册></a>
    </form>
    </body>
    <style>
        .hidden{
            display: none;
        }
    </style>
    <script>
        function ShowResult(data){
            if(data['status']!=1){
                alert(data['error']);
            }else{
                $("#go").removeClass('hidden');
                $("#login").addClass('hidden');
                $('#register').addClass('hidden');
            }
        }
        $('#login').click(function(){
            $.ajax({
                url:'/login/',
                type:'POST',
                data:{
                    'email':$('#email').val(),
                    'pwd':$('#pwd').val(),
                },
                dataType:'json',
                success:ShowResult
            })
        })
    </script>
</html>